package com.damuzee.lvyou.user.service.impl;

import com.damuzee.core.util.StringUtil;
import com.damuzee.lvyou.user.domain.UserReg;
import com.damuzee.lvyou.user.persistence.UserRegMapper;
import com.damuzee.lvyou.user.service.UserRegService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * Created by karkaw on 14-3-1.
 */

@Service
public class UserRegServiceImpl implements UserRegService {

    @Resource
    private UserRegMapper userRegMapper ;



    public void saveRegUser(String nickName ,String username,String password){
        UserReg userReg = new UserReg();
        userReg.setNickName(nickName);
        if (StringUtil.isEmail(username)){
            userReg.setEmail(username);
        }else if(StringUtil.isPhoneNo(username)){
            userReg.setPhono(username);
        }
        userReg.setPassWord(password);
        userReg.setRegDate(new Date());

        userRegMapper.save(userReg);
    }

}
